home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
gnu
/
progutil
/
stdwin.zoo
/
MANUAL
< prev
next >
Wrap
Text File
|
1989-10-17
|
48KB
|
1,193 lines
STDWIN -- STANDARD WINDOWS
--------------------------
RATIONALE
---------
STDWIN was born by the desire to make using windows both easier and more
portable for a certain class of applications. To show why it should be
easier than it currently is, consider for example the calls necessary to
create a window on the Apple Macintosh:
WindowPtr w;
Rect r;
SetRect(&r, <desired window coordinates>);
w= NewWindow(
(Ptr)nil, /* Optional storage */
&r, /* Initial position/size */
documentProc, /* Border frame type */
"Untitled", /* Title */
true, /* Immediately visible */
0L, /* Reference constant */
(WindowPtr)-1 /* Behind no other window */
);
Since I'm doing this without documentation, I may have missed or
reversed some parameters, which shows exactly what I want to illustrate:
the call has too many options, most of which are of no interest to most
application programmers. Also, it forces the programmer to invent an
initial position for the window, which is often a burden, since this
means one also has to invent a scheme by which to offset the position
for subsequent windows, to avoid creating windows that overlap exactly.
What this example doesn't show is the amount of code one has to write
to provide the functionality that Mac users expect from even the
simplest application: windows can be moved, resized, zoomed, closed,
(de)activated, scrolled in two directions, and need to be explicitly
redrawn when they pop up from below another window; none of this is done
automatically by the window manager. One needs hundreds of lines of
code to provide all this functionality, and most of it has to be
interspersed with application-dependent code (such as to actually draw a
window's contents), which makes it harder to reuse the same code in the
next program one writes.
There are other burdens to the application programmer who writes for the
Macintosh, such as the large number of #include files that one must put
in even the simplest programs, and the correspondingly large number of
initialization calls one must make.
Why using windows should be made more portable is clear if one considers
what is necessary to port a program to a different machine like the
Atari ST, the Commodore Amiga, or a Sun/3 running Suntools or X Windows
(while all these use the same type of processor!). Not only are the
calls that interface to their window managers different, the semantics
of windows are also subtly different. Some systems remember a window's
contents when it is covered by another window, so 'update events' are
unheard of; some systems provide a standard interface to scroll bars or
other tools; etc., etc.
This seriously limits productivity of application programmers: it can
take many person-months to port a successful program to a new machine,
even though one has used a high-level programming language such as C or
Pascal. While this effort may be economically justifyable for
bestsellers like commercial spreadsheets or wordprocessors, there is a
large class of applications where one can simply not afford these
porting efforts, especially in the academic world, but also for many
specialized applications which aim at a more limited market.
The current design places an emphasis on full-function windows that give
a scrollable 'view' on some kind of two-dimensional document, e.g. a
program text editor or a graphics design program. It provides some
tools for simple modal input (e.g., to ask for a string or a file name)
and gives a clean but powerful interface to the common types of pop-up
or pull-down menus (with text items only). What is clearly missing is a
mechanism to put indicators, icons, controls, rulers, palettes, tool
wells and other gadgets in the window border or on the 'desktop', and
the ability to pop up a collection of gadgets in a dialog window as
commonly seen on the Mac. Suggestions for a general mechanism here
which fits in STDWIN's philosophy are welcome. (Are there any other
systems besides the Macintosh and its derivatives like the ST or the
Amiga that provide tools for controls and dialogs?)
I haven't placed too much emphasis on the design of the graphics
primitives that must be used to draw the contents of a window. There
are simple routines to draw text strings in a single proportionally
spaced font with a few stylistic variations, and to do simple line
drawings and a few rasterop operations on rectangles. I plan to extend
the repertoire (and to implement defined functions) as the need arises;
ideally, a standard such as GKS should be adopted, if we want fo
accommodate applications with more drawing requirements. The is nothing
in the interface definition which precludes color drawing.
Although the documentation clearly describes the interface to a library
of C functions, it shouldn't be to hard to translate the interface to
other languages like FORTRAN or Modula. Ideally, STDWIN should be
defined as a set of 'abstract' functions for which language bindings can
be provided, similarly to the definition of GKS.
--- Postscript ---
The general aim of STDWIN is to provide high-level features to
applications which can be used with little effort. Features provided
must be implementable on top of a large number of window managers;
therefore, no precise definitions of some semantical aspects of windows
can be given, in order not to rule out certain implementations (example:
there can be no mention of a 'stack' of windows, since we want to be
compatible with tiling window managers). This may impair the freedom of
applications, but will enforce a useful standardization of applications
running on a particular system.
In many cases STDWIN provides a way to change the default behaviour
if this is considered useful for the application; sometimes such
default-changing routines have an optional or approximate effect,
depending on whether they can be implemented on a particular system.
For best effect this may require some system-dependent tuning when an
application is ported.
DEFINITIONS OF TERMS
--------------------
Here are short definitions of many of the terms used in the descriptions
below. Not all of these definitions are as precise as they could or
should be. Suggestions for improvement (also about the order of
presentation) are welcome.
Window
A (usually) rectangular area on the screen which contains a view
on a document. A window is linked to one particular document;
it has a title and 'borders', which usually contain scroll bars,
a grow box and possibly other controls and indicators. The end
user may usually change a window's position and size, as well as
the part of the document onto which the window gives a view.
Document
The (abstract) data structure onto which a window gives a view.
A document is a rectangular portion of the plane, with maximum h
and v coordinates which can be set by the application, but it is
NOT a bitmap: a document may be much larger than the largest
bitmap that fits in main memory, and it is defined by a 'draw
procedure'.
Window tag
A small (16-bit) integer used to distinguish windows. It is set
by the application.
Draw procedure
The function that defines a document. When called with the
coordinates of a rectangle, it should draw (at least) that part
of the document that lies within this rectangle, using the
drawing primitives provided by STDWIN, e.g. wdrawline()
and wdrawtext().
Document coordinates
All coordinates passed to and from STDWIN functions use a
coordinate system called 'document coordinates'. These are
derived through translation from window or screen coordinates:
the origin of the document is called (0, 0), independent of its
position on the screen or in the window. This origin is
positioned in the UPPER left corner of the document, with the
positive horizontal (h) axis pointing right and the positive
vertical (v) axis pointing DOWN. Document coordinates are
specified as integers.
Pixels
Are the units of measurement of document (and other)
coordinates. The size of a pixel is system-dependent; on most
screens it is equal to a screen pixel, but on alphanumeric
displays it equals a character. There is no guara